package com.edu.exam.enums.examination;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 连接状态枚举
 */
@Getter
@AllArgsConstructor
public enum ConnectionStatus {
    CONNECTED("CONNECTED", "已连接"),
    DISCONNECTED("DISCONNECTED", "未连接"),
    CONNECTING("CONNECTING", "连接中"),
    ERROR("ERROR", "连接错误"),
    TIMEOUT("TIMEOUT", "连接超时"),
    OFFLINE("OFFLINE", "离线状态"),
    BUSY("BUSY", "忙碌状态"),
    MAINTENANCE("MAINTENANCE", "维护中"),
    UNKNOWN("UNKNOWN", "未知状态"),
    READY("READY", "就绪状态"),
    FAILED("FAILED", "连接失败"),
    LIMITED("LIMITED", "受限连接");

    private final String code;
    private final String description;

    public static ConnectionStatus fromCode(String code) {
        for (ConnectionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return UNKNOWN; // 默认返回未知状态
    }
}